package com.jp.factoy.dao;


import com.jp.factoy.pojo.Factory;
import com.jp.factoy.pojo.FactorySelectVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Administrator on 2019/6/13.
 */
@Mapper
public interface FactoryMapper {


    @Insert("INSERT INTO factory(fcode,content,state,creatTime,creatName,updateTime,updateName,lcode,lname)" +
            "VALUES (#{fcode},#{content},#{state},#{createTime},#{createName},#{updateTime},#{updateName},#{lcode},#{lname})")
    int addFactory(Factory factory);


    @Select("SELECT * from factory where fcode=#{fcode}")
    List<Factory> queryFactoryCode(String fcode);

    @Update(" update factory set fcode=#{fcode}," +
            "content=#{content},state=#{state},updateTime=#{updateTime}," +
            "updateName=#{updateName},lcode=#{lcode},lname=#{lname} where fid=#{fid}")
    int updateFactory(Factory factory);

    @Update("update factory set state=#{state} where fid=#{fid}")
    int updateState(Factory factory);

    List<Factory> queryPage(FactorySelectVo factorySelectVo);

    int queryCount(FactorySelectVo factorySelectVo);

    @Select("select * from factory where fid=#{fid};")
    Factory queryFactoryById(Integer fid);
}
